import { ref, computed } from 'vue'
import { defineStore } from 'pinia'

export const useTokenStore = defineStore('token', () => {
    //定义一个响应式状态
    const token = ref(null);
    //定义getter 方法
    const tokenStr = computed(() => {
        return token.value;
    })

    const update = (tk) => {
        token.value = tk
    }
    
    const $reset = () =>{
        token.value = null
    };
    return {token, tokenStr, update, $reset}
},{
    persist: true
})